package com.quasar.hpatient.view.adapter;

import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.quasar.hpatient.R;
import com.quasar.hpatient.model.custommodel.BagFileDataBean;
import com.quasar.hpatient.model.custommodel.PhotoModel;
import com.quasar.hpatient.model.medicalmodel.ArchivesData;
import com.quasar.hpatient.network.RetrofitConnection;
import com.quasar.hpatient.widget.AutoHeightGridView;

import java.util.ArrayList;

/**
 * author : 许建宏
 * Date: 2017/10/31 0031
 * View:档案袋
 */

public class BagFileAdapter  extends BaseQuickAdapter<BagFileDataBean, BaseViewHolder> {

    public BagFileAdapter() {
        super(R.layout.bag_file_item);
    }


    @Override
    protected void convert(BaseViewHolder helper, BagFileDataBean item) {

        //日期
        if (item.getTime() != null) {
            helper.setText(R.id.por_tv_time, item.getTime().substring(0, 10));
        }

        ImageAdapter adapter;
        final ArrayList<PhotoModel> pms = new ArrayList<>();
        AutoHeightGridView images = helper.getView(R.id.gridView);
        ImageView iv_pull_down=helper.getView(R.id.iv_pull_down);
        iv_pull_down.setVisibility(View.INVISIBLE);

        if (item.getBagFileItems() != null) {
            for (int i = 0; i < item.getBagFileItems().size(); i++) {
                pms.add(new PhotoModel(RetrofitConnection.PHOTOURL + item.getBagFileItems().get(i).getCover()));
            }

            adapter = new ImageAdapter(mContext, pms);
            images.setAdapter(adapter);
            images.setOnItemClickListener(adapter);
        }
    }
}
